As we venture into the era of Fourth Industry Revolution, we welcome ChatGPT, a remarkable AI chatbot developed by OpenAI, revolutionising the way we interact with computer-based agents. Harnessing the power of the GPT family of large language models, ChatGPT enables users to engage in human-like conversations, effortlessly comprehending and responding to natural language input. Despite its limitations, such as occasional hallucinations and biases, Rapid advancements in generative AI, including domain-specific models like BloombergGPT, are paving the way for innovative applications in various industries, such as finance and investment, as we usher in a data-driven and efficacious financial milieu.
The power of large language models like ChatGPT is immense, but to fully harness this potential, effective prompt engineering is crucial. In this blog, we will introduce prompt engineering principles, explore the “genius in a room” mental model, and discuss best practices for crafting questions/prompts to get the most out of ChatGPT. We also present the recent practice of BloombergGPT in Finance. We also present the recent practice of BloombergGPT model in Finance NLP. By the end of this guide, you’ll be well-equipped to create more instructive and enlightening prompts that maximize the benefits of this cutting-edge AI.
ChatGPT, a chatbot developed by OpenAI and based on the Generative Pre-trained Transformer (GPT) model architecture, enables users to engage in human-like conversations with a computer-based agent. Launched in November 2022, ChatGPT utilises large-scale deep learning NLP algorithms - nowadays called as Large Language Model (LLM) - to analyse text input and generate responses, making it suitable for a variety of purposes, such as answering questions and casual conversation. Built on the GPT+ family of large language models (currently GPT-4 as of 03/31/2023), ChatGPT has been fine-tuned with both supervised and reinforcement learning techniques and trained on vast amounts of text data, providing extensive knowledge that is available in Internet.
A key advantage of ChatGPT lies in its ability to comprehend and respond to natural language input in a nature way as human, enabling users to communicate using familiar language and syntax. Additionally, ChatGPT’s capacity to understand context allows it to produce more appropriate, relevant and human-like responses.
Prompt engineering is the process of crafting questions or statements that guide the AI model like ChatGPT to generate desired responses. However, their performance is heavily dependent on the clarity, context, and specificity of these prompts. Effective prompt engineering ensures that the model understands the user’s intent, leading to more accurate and relevant responses to harness its full potential.
Tailor Prompted. Different applications and contexts may require unique output formats, tones, or styles. Prompt engineering allows users to customize their interactions with ChatGPT by specifying these requirements explicitly. This ensures that the generated responses meet the user’s expectations and are suitable for the intended purpose.
Limitation - Despite its impressive capabilities, ChatGPT has some limitations that users should be aware of:
Hallucinations: ChatGPT may sometimes generate text that appears plausible but is factually incorrect or entirely fictional. This is known as “hallucination” and can be challenging to identify without prior knowledge of the subject matter.
Ambiguity Handling: If a prompt is ambiguous or unclear, ChatGPT-4 might guess the user’s intent rather than seeking clarification, which could lead to misleading or irrelevant responses.
Bias: The current offline ChatGPT is trained on vast amounts of text data from the internet up till September 2021, it may inadvertently reflect and perpetuate biases present in those data sources. This means ChatGPT is NOT omniscient and sometime it will generate fake answers. The future version will enable the browsing ability and can mitigate some problems.
Figure 2.1: Source: https://twitter.com/JessicaShieh
When crafting questions or prompts for ChatGPT, one intuitive mindset is imagine you live next door to a genius (credit to Jessica Shieh @OpenAI). This person is incredibly knowledgeable, but they have no context on you or the problems you’re trying to solve. To communicate with them, you can only slide a piece of paper under the door and await their reply.
With this mental model in mind, context is key. You want to make sure that your queries are clear, concise, and provide enough context for the AI model to understand what you’re looking for. Providing the right context can dramatically improve the quality of the output you receive from ChatGPT. To accomplish this, consider the following best practices:
Explain the Problem - Make sure to clearly outline the problem you want the model to solve. This includes providing any necessary background information and setting the stage for the task at hand.
Example: Prompt: “As an AI language model, can you help me write an email to my professor asking for an extension on my project deadline due to unforeseen circumstances?”
Articulate the Desired Output - Specify the format, tone, and style you want the response to be in. By doing so, you guide the model to provide an output that aligns with your expectations.
Example: Prompt: “Write a concise and polite email to my professor, requesting an extension on my project deadline due to unforeseen circumstances.”
Provide Unique Knowledge - If the task requires specific knowledge, make sure to include that information in your prompt. Remember, ChatGPT’s knowledge is limited up to September 2021.
Example: Prompt: “Using the following data from a recent study (insert study data here), can you help me analyze the correlation between variable A and variable B?”
Break Down Complex Tasks - Divide a complex task into smaller, more manageable components. This allows ChatGPT to focus on one aspect at a time, increasing the likelihood of receiving accurate and useful output.
Example: Instead of: “Write a detailed comparison of renewable energy sources.” Try: “First, list the main types of renewable energy sources. Then, describe the advantages and disadvantages of each type.”
Chain-of-thought prompting (CoT) is a method that allows AI language models to break down multi-step problems into intermediate steps, which are then solved individually. This approach facilitates a deeper understanding of the problem and the reasoning process, making it applicable to a wide range of tasks that can be solved through language-based reasoning. Empirical experiments have shown that chain-of-thought prompting significantly improves performance on various reasoning tasks, but its benefits only materialize when the model has a sufficient number of parameters (around 100 billion).
One advantage of chain-of-thought prompting, as compared to other techniques, is the ability to specify the format, length, and style of reasoning the model should employ before arriving at a final answer. This level of control can be particularly useful when the model isn’t initially reasoning in the desired way or depth. This means you could correct the agent’s answer to iteratively improve the output result during the chatting interaction.
Figure 3.1: Source: Chain of Thought Prompting Elicits Reasoning in Large Language Models Jason Wei and Denny Zhou et al. (2022)
“Let’s think step by step” prompt is one practical approach to prompt engineering that encourages AI language models to reason through problems in a structured manner. By explicitly requesting the model to think step by step, users can guide it to consider intermediate steps before arriving at a final answer. Although the few-shot example-based approach offers more control over the format, length, and style of reasoning, the “Let’s think step by step” technique can be beneficial when the model isn’t initially reasoning in the desired manner or depth. By incorporating this technique into your prompt engineering toolkit, you can ensure a more comprehensive and effective problem-solving process with AI language models. s
Figure 3.2: Source: Large Language Models are Zero-Shot Reasoners by Takeshi Kojima et al. (2022)
If you apply this technique to your own tasks, don’t be afraid to experiment with customizing the instruction. Let’s think step by step is rather generic, so you may find better performance with instructions that hew to a stricter format customized to your use case. For example, you can try more structured variants like First, think step by step about why X might be true. Second, think step by step about why Y might be true. Third, think step by step about whether X or Y makes more sense.
Researchers have found that chain-of-thought prompting can yield impressive improvements in problem-solving performance. For instance, when applied to grade school math problems, it tripled the solve rate from 18% to 57%. Beyond math, this technique has also demonstrated enhanced performance in tasks related to sports understanding, coin flip tracking, and last letter concatenation.
To solve {question}, we need to first solve: - While chain-of-thought prompting is highly effective in many scenarios, it can struggle with tasks involving long reasoning chains or when the examples are short but the task is complex. In such cases, alternative techniques like least-to-most prompting can be employed. This approach breaks complex tasks into smaller, more reliable subtasks by prompting the model to first identify a subtask that needs to be solved, then generate a solution, and finally repeat the process until a final answer is produced.
Figure 3.3: Source: Least-to-most Prompting Enables Complex Reasoning in Large Language Models by Denny Zhou et al. (2022)
Association Towards Reasoning - The field of large language models is constantly evolving and undergoing active research. Not only are these models being improved upon, but researchers are also gaining a better understanding of how to effectively utilize them. As we look towards the future, we can expect to see continued advancements in both the models themselves and the techniques used to optimize them. While the specific methods discussed may eventually be surpassed by newer practices, the foundational principles they represent are likely to remain an essential aspect of any expert user’s skillset.
Figure 3.4: Chain of Paper Thoughts
The financial industry has seen a growing interest in the application of natural language processing (NLP) technologies, such as sentiment analysis, named entity recognition, and question answering. While general large language models (LLMs) have proven effective in various tasks, there is a demand for LLMs specifically tailored to the financial domain.
BloombergGPT is a 50 billion parameter large language model - comparable to GPT-3 - developed to address the unique challenges and complexities of the financial industry. Trained on a mixed dataset, including Bloomberg’s extensive financial data and general-purpose datasets, BloombergGPT aims to excel in both financial and general-purpose tasks.
Figure 4.1: BloombergGPT Model Size
FinPile Dataset - To train BloombergGPT, researchers constructed “FinPile,” a comprehensive dataset comprising English financial documents such as news, filings, press releases, and social media content from Bloomberg archives. This dataset was combined with public data to create a training corpus of over 700 billion tokens, evenly split between domain-specific and general-purpose text.
The performance of BloombergGPT was evaluated on both finance-specific and general-purpose tasks. In the finance-specific tasks, the model outperformed existing models on most benchmarks. For general-purpose tasks, BloombergGPT demonstrated performance comparable to or better than previously published results.
Figure 4.2: BloombergGPT Model Size
Some notable use cases for BloombergGPT include:
Generation of Bloomberg Query Language (BQL): BloombergGPT simplifies the complex BQL, transforming natural language queries into valid BQL and making it more accessible to users.
Suggestion of News Headlines: As BloombergGPT is trained on numerous news articles, it can effectively assist journalists in creating short headlines for each new section.
Financial Question Answering: The model’s financial domain training enables it to answer questions relevant to the financial world, such as identifying the CEO of a company.
Unsuprisingly, the BloombergGPT model’s release is limited due to claimed privacy concerns related to FinPile data access. Nonetheless, the development of BloombergGPT contributes to the ongoing discussion favoring the effective training of domain-specific models and balancing performance across different domains, in-domain data still matters. Future research directions include task fine-tuning, and understanding the impact of tokenization strategy on the resulting model.
Take-home Act As Trick - the “act as” hack involves instructing ChatGPT to assume a specific role or persona by incorporating the phrase “act as” followed by the desired role or persona. This approach allows users to tailor ChatGPT interactions to their specific interests and requirements, enhancing the overall experience and effectiveness of the AI model. Here, we present an example in which ChatGPT assumes the role of a quantitative researcher, providing insights as a quant, which we deem to be quite an impressive response:
Figure 5.1: ChatGPT QR
As the field of prompt engineering continues to evolve, the capabilities of AI models like ChatGPT are expanding rapidly. Today’s limitations, such as challenges with math and logic, may very well be overcome in the near future, unlocking new possibilities for generative AI in various industries, including finance and investment. For example, the qualitative information in text format within fiance domain such as top analyst reports remains a goldmine to exploit with new state-of-the-art NLP processing ability.
Quant\(\times\)AI - The auspicious future of ChatGPT and AI in quantitative investment beckons a new era of innovation and growth. As we embrace and stay attuned to the rapid advancements in generative AI, we are poised to unlock the full potential of AI within the finance and investment applications. Thus, as we cast our gaze toward the horizon, we can anticipate a world that seamlessly melds artificial intelligence and quantitative investment, ushering in a data-driven and efficacious financial milieu.